import { Tag } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import React, { useState, useEffect } from 'react';
import { connect } from 'umi';
import Avatar from './AvatarDropdown';
import styles from './index.less';
// import NoticeView from './NoticeIconView';
import CollectionCreateForm from '@/components/CreateForm/createForm';

const ENVTagColor = {
  dev: 'orange',
  test: 'green',
  pre: '#87d068',
};

const GlobalHeaderRight = (props) => {
  const { theme, layout, global, dispatch } = props;
  const { changePwd } = global;
  const onCreate = (values) => {
    handleEditPwd(values);
    setVisible(false);
  };

  const handleEditPwd = (values) => {
    if (dispatch) {
      dispatch({
        type: 'global/changePwd',
        payload: values,
      });
    }
  };
  let className = styles.right;

  if (theme === 'dark' && layout === 'top') {
    className = `${styles.right}  ${styles.dark}`;
  }

  return (
    <div className={className}>
      <Avatar />
      {/* <div>2020-10-2 16:48</div> */}
      {/* <span>当前时间：2020-10-2 16:48</span> */}

      {/* {REACT_APP_ENV && (
        <span>
          <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>
        </span>
      )} */}
      <CollectionCreateForm
        visible={changePwd}
        onCreate={onCreate}
        shouldOld={false}
        onCancel={() => {
          dispatch({
            type: 'global/changePwdShow',
            payload: false,
          });
        }}
      />
    </div>
  );
};

export default connect(({ settings, global }) => ({
  theme: settings.navTheme,
  layout: settings.layout,
  global,
}))(GlobalHeaderRight);
